package liguo.util;

import android.databinding.BindingAdapter;
import android.text.Html;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;

import java.util.List;

import liguo.application.BaseApplication;
import liguo.views.RoundImageView;

/**
 * Created by Extends on 2017/3/22.
 */

public class BindingAdapterUtil {

    @BindingAdapter({"imgSrc"})
    public static void loadImage(ImageView view, int imgId) {
        view.setImageResource(imgId);
    }

    @BindingAdapter({"spinner_updata"})
    public static void updata(Spinner spinner, List<String> list){
        ArrayAdapter adapter = new ArrayAdapter<>(BaseApplication.getContext(), android.R.layout.simple_spinner_item, list);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
    }

    @BindingAdapter({"textHtml"})
    public static void setTextHtml(TextView view, String html) {
        view.setText(Html.fromHtml(html));
    }

    @BindingAdapter({"setSeep"})
    public static void setSeep(RoundImageView view, String seep) {
        view.setSeed(seep);
    }

    @BindingAdapter({"setBorderInsideColor"})
    public static void setBorderInsideColor(RoundImageView view, Boolean b) {
        view.setThicknessAndOutColor(Util.dip2px(2f),b?0xffff0000:0x00ff0000);
    }

}
